home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / DSAKeyPairGenerator.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  100 lines

  1. /*
  2.  * @(#)DSAKeyPairGenerator.java    1.6 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.security.interfaces;
  16.  
  17. import java.security.*;
  18.  
  19. /**
  20.  * An interface to an object capable of generating DSA key pairs. 
  21.  *
  22.  * <p>The <code>initialize</code> methods may each be called any number 
  23.  * of times. If no <code>initialize</code> method is called on a 
  24.  * DSAKeyPairGenerator, the default is to generate 1024-bit keys, using 
  25.  * precomputed p, q and g parameters and an instance of SecureRandom as 
  26.  * the random bit source.
  27.  * 
  28.  * <p>Users wishing to indicate DSA-specific parameters, and to generate a key 
  29.  * pair suitable for use with the DSA algorithm typically
  30.  * 
  31.  * <ol>
  32.  * 
  33.  * <li>Get a key pair generator for the DSA algorithm by calling the 
  34.  * KeyPairGenerator <code>getInstance</code> method with "DSA" 
  35.  * as its argument.<p> 
  36.  * 
  37.  * <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
  38.  * and calling one of the 
  39.  * <code>initialize</code> methods from this DSAKeyPairGenerator interface.<p>
  40.  * 
  41.  * <li>Generate a key pair by calling the <code>generateKeyPair</code> 
  42.  * method from the KeyPairGenerator class.
  43.  * 
  44.  * </ol> 
  45.  *
  46.  * <p>Note: it is not always necessary to do do algorithm-specific
  47.  * initialization for a DSA key pair generator. That is, it is not always
  48.  * necessary to call an <code>initialize</code> method in this interface.
  49.  * Algorithm-independent initialization using the <code>initialize</code> method
  50.  * in the KeyPairGenerator
  51.  * interface is all that is needed when you accept defaults for algorithm-specific
  52.  * parameters.
  53.  * 
  54.  * @see java.security.KeyPairGenerator
  55.  */
  56. public interface DSAKeyPairGenerator {
  57.  
  58.     /**
  59.      * Initializes the key pair generator using p, q and g, the DSA
  60.      * family parameters.
  61.      *
  62.      * @param params the parameters to use to generate the keys.
  63.      *
  64.      * @param random the random bit source to use to generate 
  65.      * key bits.
  66.      *
  67.      * @exception InvalidParameterException if the parameters passed are
  68.      * invalid or null.
  69.      */
  70.    public void initialize(DSAParams params, SecureRandom random)
  71.    throws InvalidParameterException;
  72.  
  73.     /**
  74.      * Initializes the key pair generator for a given modulus length,
  75.      * without parameters. 
  76.      *
  77.      * <p>If <code>genParams</code> is true, this method will generate new 
  78.      * p, q and g parameters. If it is false, the method will use precomputed
  79.      * parameters for the modulus length requested. If there are no
  80.      * precomputed parameters for that modulus length, an exception will be 
  81.      * thrown. It is guaranteed that there will always be
  82.      * default parameters for modulus lengths of 512 and 1024 bits.
  83.      *
  84.      * @param modlen the modulus length, in bits. Valid values are any
  85.      * multiple of 8 between 512 and 1024, inclusive.
  86.      *
  87.      * @param random the random bit source to use to generate 
  88.      * key bits.
  89.      *
  90.      * @param genParams whether or not to generate new parameters for
  91.      * the modulus length requested.
  92.      *
  93.      * @exception InvalidParameterException if the modulus length is not
  94.      * between 512 and 1024, or if genParams is false and there are
  95.      * not precomputed parameters for the modulus length requested.  
  96.      */
  97.     public void initialize(int modlen, boolean genParams, SecureRandom random)
  98.     throws InvalidParameterException;
  99. }
  100.